ScanFlowConfiguration

data class ScanFlowConfiguration(var source: ScanFlowConfiguration.Source = Source.CAMERA, var sourceImage: File? = null, var multiPage: Boolean = true, var defaultFilter: ScanFlowConfiguration.Filter = Filter.AUTOMATIC, var availableFilters: List<ScanFlowConfiguration.Filter> = listOf( Filter.NONE, Filter.AUTOMATIC, Filter.AUTOMATIC_MONOCHROME, Filter.AUTOMATIC_BLACK_AND_WHITE, Filter.AUTOMATIC_COLOR, Filter.PHOTO ), var pdfPageSize: ScanFlowConfiguration.PdfPageSize = PdfPageSize.FIT, var skipPostProcessingScreen: Boolean = false, var postProcessingActions: EnumSet<ScanFlowConfiguration.Action> = Action.ALL, var defaultCurvatureCorrection: ScanFlowConfiguration.CurvatureCorrectionMode = CurvatureCorrectionMode.DISABLED, var defaultScanOrientation: ScanFlowConfiguration.Orientation = Orientation.AUTOMATIC, var photoLibraryButtonHidden: Boolean = false, var flashButtonHidden: Boolean = false, var defaultFlashMode: ScanFlowConfiguration.FlashMode = FlashMode.OFF, @ColorInt var backgroundColor: Int = Color.BLACK, @ColorInt var foregroundColor: Int = Color.WHITE, @ColorInt var highlightColor: Int = Color.BLUE, var jpegQuality: Int = 60, var pdfMaxScanDimension: Int = 0, var multiPageFormat: ScanFlowConfiguration.MultiPageFormat = MultiPageFormat.PDF, var pdfFontFile: File? = null, var outputDirectory: File? = null, var ocrConfiguration: ScanFlowConfiguration.OcrConfiguration? = null, var structuredData: EnumSet<ScanFlowConfiguration.StructuredData> = EnumSet.noneOf(StructuredData::class.java), var structuredDataBarcodeTypes: EnumSet<Barcode.Type> = EnumSet.allOf(Barcode.Type::class.java), var requiredReadabilityLevel: ScanProcessor.ReadabilityLevel = ScanProcessor.ReadabilityLevel.Lowest, var pdfPassword: String? = null, var showFinalReview: Boolean = false, var showCropValidation: ScanFlowConfiguration.CropValidation = CropValidation.Never) : Serializable

Options for capturing, reviewing, and exporting scans with ScanFlow. Pass a configuration to ScanActivity.Contract or ScanFlow.scanWithConfiguration.

Use defaultFilter to choose the initial enhancement for each page and availableFilters to choose the filters offered to the user. See Filter for all filters and when to use them. For example, start with color enhancement and offer a smaller selection of filters:

import com.geniusscansdk.scanflow.ScanFlowConfiguration
import com.geniusscansdk.scanflow.ScanFlowConfiguration.Filter

val configuration = ScanFlowConfiguration(
defaultFilter = Filter.AUTOMATIC_COLOR,
availableFilters = listOf(
Filter.AUTOMATIC_COLOR,
Filter.AUTOMATIC_BLACK_AND_WHITE,
Filter.NONE
)
)

To keep the same filter for every page, set defaultFilter and omit Action.EDIT_FILTER from postProcessingActions. This example still lets the user rotate scans and toggle distortion correction:

import com.geniusscansdk.scanflow.ScanFlowConfiguration
import com.geniusscansdk.scanflow.ScanFlowConfiguration.Action
import com.geniusscansdk.scanflow.ScanFlowConfiguration.Filter
import java.util.EnumSet

val configuration = ScanFlowConfiguration(
defaultFilter = Filter.AUTOMATIC_MONOCHROME,
postProcessingActions = EnumSet.of(Action.ROTATE, Action.CORRECT_DISTORTION)
)

Constructors

Link copied to clipboard
constructor(source: ScanFlowConfiguration.Source = Source.CAMERA, sourceImage: File? = null, multiPage: Boolean = true, defaultFilter: ScanFlowConfiguration.Filter = Filter.AUTOMATIC, availableFilters: List<ScanFlowConfiguration.Filter> = listOf( Filter.NONE, Filter.AUTOMATIC, Filter.AUTOMATIC_MONOCHROME, Filter.AUTOMATIC_BLACK_AND_WHITE, Filter.AUTOMATIC_COLOR, Filter.PHOTO ), pdfPageSize: ScanFlowConfiguration.PdfPageSize = PdfPageSize.FIT, skipPostProcessingScreen: Boolean = false, postProcessingActions: EnumSet<ScanFlowConfiguration.Action> = Action.ALL, defaultCurvatureCorrection: ScanFlowConfiguration.CurvatureCorrectionMode = CurvatureCorrectionMode.DISABLED, defaultScanOrientation: ScanFlowConfiguration.Orientation = Orientation.AUTOMATIC, photoLibraryButtonHidden: Boolean = false, flashButtonHidden: Boolean = false, defaultFlashMode: ScanFlowConfiguration.FlashMode = FlashMode.OFF, @ColorInt backgroundColor: Int = Color.BLACK, @ColorInt foregroundColor: Int = Color.WHITE, @ColorInt highlightColor: Int = Color.BLUE, jpegQuality: Int = 60, pdfMaxScanDimension: Int = 0, multiPageFormat: ScanFlowConfiguration.MultiPageFormat = MultiPageFormat.PDF, pdfFontFile: File? = null, outputDirectory: File? = null, ocrConfiguration: ScanFlowConfiguration.OcrConfiguration? = null, structuredData: EnumSet<ScanFlowConfiguration.StructuredData> = EnumSet.noneOf(StructuredData::class.java), structuredDataBarcodeTypes: EnumSet<Barcode.Type> = EnumSet.allOf(Barcode.Type::class.java), requiredReadabilityLevel: ScanProcessor.ReadabilityLevel = ScanProcessor.ReadabilityLevel.Lowest, pdfPassword: String? = null, showFinalReview: Boolean = false, showCropValidation: ScanFlowConfiguration.CropValidation = CropValidation.Never)

Types

Link copied to clipboard

Editing buttons available on the post-processing and page review screens. Used by postProcessingActions.

Link copied to clipboard
sealed interface CropValidation : Serializable

Options for whether the crop validation screen should be shown after a scan has been captured by the user.

Link copied to clipboard

Whether to correct distortion caused by curved or folded paper. Used by defaultCurvatureCorrection.

Link copied to clipboard

Enhancement filters for defaultFilter and availableFilters.

Link copied to clipboard

Flash behavior when capturing a page with the camera. Used by defaultFlashMode.

Link copied to clipboard

Format of the document containing the captured pages. Used by multiPageFormat.

Link copied to clipboard
data class OcrConfiguration(var languages: List<String>? = null, var outputFormats: EnumSet<ScanFlowConfiguration.OcrOutputFormat> = OcrOutputFormat.ALL) : Serializable

Languages and output formats for text recognition. Assign this to ocrConfiguration to enable OCR output. Provide at least one supported language in languages.

Link copied to clipboard

The various formats into which the OCR result can be made available.

Link copied to clipboard

How to rotate a scan after capture. Used by defaultScanOrientation.

Link copied to clipboard

Physical size of pages in the generated PDF file. Used by pdfPageSize.

Link copied to clipboard

The source of the scan flow.

Link copied to clipboard

The types of structured data to extract.

Properties

Link copied to clipboard

The filters shown in the filter selector, in display order. See Filter for all possible values. Defaults to Filter.NONE, Filter.AUTOMATIC, Filter.AUTOMATIC_MONOCHROME, Filter.AUTOMATIC_BLACK_AND_WHITE, Filter.AUTOMATIC_COLOR, and Filter.PHOTO.

Link copied to clipboard

UI background color. Default is black.

Link copied to clipboard

Whether to correct curved or folded documents by default. Defaults to CurvatureCorrectionMode.DISABLED. If postProcessingActions includes Action.CORRECT_DISTORTION, the user can override this setting for each page.

Link copied to clipboard

The initial enhancement filter for each page. Defaults to Filter.AUTOMATIC. See Filter for the available filters and their recommended uses.

Link copied to clipboard

The default flash mode used when capturing a page. Combine with ScanFlowConfiguration.flashButtonHidden if you want to only allow a specific flash mode. Default is FlashMode.OFF.

Link copied to clipboard

How to rotate scans after capture. Defaults to Orientation.AUTOMATIC. Use Orientation.ORIGINAL to keep the original orientation.

Link copied to clipboard

Whether to hide the flash button on the camera screen. Defaults to false.

Link copied to clipboard

UI foreground color (text and icons). Default is white.

Link copied to clipboard

Color of the document detection overlay. Default is blue.

Link copied to clipboard

JPEG quality used to compress captured images. Between 0 and 100, 100 being the best quality. Default is 60.

Link copied to clipboard

Whether the user can capture several pages in one camera session. Defaults to true. When false, the camera captures a single page. Only applies when source is Source.CAMERA.

Link copied to clipboard

Format of the document created with all the captured pages. When set to MultiPageFormat.NONE, no document will be generated but the individual pages will still be accessible in the ScanFlowResult. Defaults to MultiPageFormat.PDF.

Link copied to clipboard

The configuration for text recognition on each captured image. Defaults to null, which disables OCR output. To enable it, provide an OcrConfiguration with the languages to recognize. Structured-data extraction can still recognize text when needed, such as for StructuredData.RECEIPT.

Link copied to clipboard

Absolute directory where ScanFlow writes its output files.

Link copied to clipboard

Custom font file used during the PDF generation to embed an invisible text layer. If null, a default font is used, which only supports Latin languages.

Link copied to clipboard

Max scan dimension in pixels when generating the PDF file. All scans included in the PDF file will be scaled so that both their height and width are smaller than this value, while keeping their aspect ratio. Default is 0, which means no scaling is applied.

Link copied to clipboard

The size of the pages when multiPageFormat is MultiPageFormat.PDF. Defaults to PdfPageSize.FIT.

Link copied to clipboard

Optional password used to protect generated PDF documents. Defaults to null. An empty password is treated as no password. This only applies when multiPageFormat is MultiPageFormat.PDF.

Link copied to clipboard

Whether to hide the photo library button on the camera screen. Defaults to false.

Link copied to clipboard

The editing actions available on the post-processing and page review screens. Defaults to Action.ALL. These actions control the editing buttons, not the processing defaults. For example, omitting Action.EDIT_FILTER prevents the user from changing defaultFilter.

Link copied to clipboard

The readability level required for the scans. A warning will be displayed to the user if the readability of a scan is lower than this level. Defaults to ScanProcessor.ReadabilityLevel.Lowest, which does not require a minimum level of readability.

Link copied to clipboard

Controls whether the crop validation screen is automatically displayed after capture. Default is CropValidation.Never.

Link copied to clipboard

Whether to show a final review of all captured pages before submitting them for export. The user can review and edit the pages on this screen. Defaults to false.

Link copied to clipboard

Whether to skip showing the post-processing screen. We only recommend enabling this option when scanning structured data. Generally, you want the user to visually confirm the quality of each scan. Defaults to false. Image processing still runs when this screen is skipped. showCropValidation and showFinalReview control their screens independently.

Link copied to clipboard

The source for the scanned documents. Defaults to Source.CAMERA. If the source is Source.IMAGE, sourceImage must be provided. Use Source.GALLERY to let the user select an image from the photo library.

Link copied to clipboard

The image file to scan when source is Source.IMAGE. Defaults to null.

Link copied to clipboard

Types of structured data to extract from the document. Defaults to an empty set, which disables extraction. Multiple StructuredData values can be combined in an EnumSet.

Link copied to clipboard

If structuredData contains StructuredData.BARCODE, the list of barcode types to look for. Default is all supported types.